package com.smh.mianshi.listener;

import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;

/**
 * @author shiminghui
 * @date 2024/9/26 21:00
 * @description: TODO
 */
public class MyApplicationListener implements ApplicationListener {
    // 当我们的ioc容器发布事务时执行
    @Override
    public void onApplicationEvent(ApplicationEvent event) {

        if (event instanceof ApplicationReadyEvent) {
            System.out.println("容器初始化成功");
        }
        if (event instanceof ApplicationFailedEvent) {
            System.out.println("容器初始化失败");
        }

    }
}
